﻿<?php
require_once("../../class2.php");
require_once(HEADERF);
		$user_id = USERID;
		$user_name = USERNAME;
require_once("./includes/require_all.php");

ramka("open");

$idded=0;

function echofaqs($cat){
	global $idded;
	if (isset($_GET['sho'])) {
		$limit= mysql_real_escape_string($_GET['sho']);
		$cato= mysql_query("SELECT * FROM cms_faqs ORDER BY date DESC LIMIT 0,$limit");
	}
	else {
		$cato= mysql_query("SELECT * FROM cms_faqs WHERE cat='$cat' ORDER BY question ASC");
	}
	while($faq=mysql_fetch_array($cato)){
		echo<<<HTML
			<div class='forumheader2 textWHITE' style='padding:0px; padding-left:10px; cursor:pointer;' onclick="javascript:toggle('faq$idded')"><span></span>$faq[question]</div>
			<div class='forumheader textGREY' id='faq$idded' style='display:none;'><span style='margin-left:20px;'></span>$faq[answer]</div>
HTML;
		$idded++;
	}
}

function echofaqcat($cat, $titled){
	echo "<div class='forumheader3 textRED'><b>$titled</b></div>";
		echofaqs($cat);
	echo "<div class='forumheader3'></div>";
}

if (isset($_GET['sho'])) {
	echo "<div id='result'>";
	echofaqcat(0,"");
	echo "</div>";
}
else {
	echofaqcat(1,"Общи:");
	echo "<br>";
	echofaqcat(2,"За системата:");
}

ramka("close");

if (isset($_GET['sho'])) {
	CMS_activitySave("e107-index.php");
}
else CMS_activitySave("faqs.php");

require_once(FOOTERF);
?>